var Communicator    =   require("../../client/communicator").New();
var Protocol        =   require("../../rpc-json/json-client");
var ServantProxy    =   require("../../client/servantProxy");

var prx = Communicator.stringToProxy(ServantProxy, "echo@tcp -h 127.0.0.1 -p 12306 -t 60000");
prx.setProtocol(Protocol);
prx.setTimeout(30000);

var success = function (result) {
    console.log("result.response.costtime:",    result.response.costtime);
    console.log("result.response.appBuffer",    result.response.appBuffer);
}

var error = function (result) {
    console.log("result.response.error.code:",    result.response.error.code);
    console.log("result.response.error.message:", result.response.error.message);
}

//第一种使用方法
prx.rpc.createFunc("echo");
prx.rpc.echo("echo1", "message", {a : 1, b : 2}).then(success, error).done();

//第二种使用方法
prx.rpc_call(1, "echo", ["message2", "message3", {a : 1, b : 2}]).then(success, error).done();
